package cn.wolfcode.crm.web.controller;


import cn.wolfcode.crm.domain.ProductSort;
import cn.wolfcode.crm.service.IProductSortService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("productSort")
public class ProductSortController {
    @Autowired
    private IProductSortService productSortService;

    @RequestMapping("query")
    @ResponseBody
    public Object selectAll() {
        //将数据转换成json格式
        List<ProductSort> productSorts = productSortService.selectAll();
        return productSorts;
    }

    @RequestMapping("view")
    public String view(Model model, Long id) {
        return "/productSort/productSort";
    }




    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate( ProductSort entity) {
        productSortService.saveOrUpdate(entity);
        return new JSONResult();
    }

    @RequestMapping("delete")
    @ResponseBody
    public Object delete( Long id) {
        productSortService.deleteByPrimaryKey(id);
        return new JSONResult();
    }
}
